
    
    /*
     * 
     * 
     * @copyright (c) 2010 David Foley
     * @license New BSD
     */
    String.implement.preventOverride= true;
    String.implement
    (
        {
            /**
             * Trim leading and trailing whitespace from a string.
             * 
             * @example alert(' characters '.trim()); // 'characters'
             * @return {String}
             */
            trim: function () 
            {                    
                var	str = this.replace(/^\s\s*/, ''),
    				ws = /\s/,
    				i = str.length;
    			while (ws.test(str.charAt(--i)));
    			return str.slice(0, i + 1);
            }
            
            /**
             * Determine if a string is empty or not. A string qualifies as
             * empty if it has a length of 0 or consists only of whitespace
             * 
             * @example alert(''.isEmpty()); // true
             * @example alert('   '.isEmpty()); // true
             * @example alert(new String().isEmpty()); // true
             * @example alert(' !'.isEmpty()); // false
             * 
             * @return {Boolean}
             * @see String.nonEmpty
             */
        ,   isEmpty: function () 
            {
                if (0 === this.length)
                    return true;
                    
                return 0 === this.trim().length;
            }
            
            /**
             * Prepend a string to the begining of this string
             * 
             * @example alert('o'.prepend('hell')); // 'hello'
             * @param {String} value
             * @return {string}
             */
        ,   prepend: function (value) 
            {
                return String(value) + this;
            }
            
            /**
             * Append a string to the end of this string.
             * 
             * @example alert('hell'.append('o')); // 'hello'
             * @param {String} value
             * @return {String}
             */
        ,   append: function (value) 
            {
                return this + String(value);
            }
            
            /**
             * Determine if this string begins with the value of another.
             * 
             * @example alert ('hello'.beginsWith('hell')); // true
             * 
             * @param {String} value
             * @return {Boolean}
             */
        ,   beginsWith: function (value) 
            {
                return String(value) == this.substr(0, value.length);
            }
            
            /**
             * Determine if this string ends with the value of another.
             * 
             * @example alert('hello'.endsWith('lo')); // true
             * @param {String} value
             * @return {Boolean}
             */
        ,   endsWith: function (value) 
            {
                return String(value) == this.substr(this.length - value.length);
            }
        }
    );
    
    String.implementStatic
    (
        {
            
            /**
             * Determine if a value is a non-empty string. In order to qualify,
             * the value must be a string of greater than zero length and contain
             * at least one non-whitespace character.
             * 
             * @param {Object} value    Any value.
             * @return {Boolean}        Whether the value is a non-empty string
             */
            notEmpty: function (value) 
            {
                return String.type(value) && !value.isEmpty();
            }
        }
    );
